<template>
  <div class="log-page">
    <el-form inline>
      <el-form-item label="品牌名称">
        <el-input v-model="searchParams.name" clearable placeholder="输入品牌名称" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" style="margin-left: 15px" @click="onSearch">搜索</el-button>
        <el-button @click="onReset">重置</el-button>
      </el-form-item>
    </el-form>
    <div class="line" />
    <div style="margin-bottom: 20px">
      <el-button type="primary" plain icon="el-icon-plus" @click="onAdd">添加品牌</el-button>
    </div>
    <div class="table-box">
      <el-table
        v-loading="loading"
        height="100%"
        stripe
        :data="tableData"
        element-loading-spinner="el-icon-loading"
        element-loading-background="rgba(255, 255, 255, 0.8)"
        @selection-change="onSelect"
      >
        <el-table-column
          v-for="item in columns"
          :key="item.prop"
          :prop="item.prop"
          :label="item.label"
          align="left"
        />
        <el-table-column label="操作" fixed="right" width="140px">
          <template slot-scope="scope">
            <el-button
              type="text"
              @click="onEdit(scope.row)"
            >编辑</el-button>
            <el-button
              type="text"
              @click="onFrozen(scope.row)"
            >冻结</el-button>
            <el-button
              type="text"
              @click="onDelete(scope.row)"
            >删除</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <div class="page-box">
      <el-pagination
        background
        :current-page="pageNo"
        :page-sizes="pageSizes"
        :page-size="pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="totalSize"
        @size-change="changePageSize"
        @current-change="changePageNo"
      />
    </div>
    <Edit ref="EditRef" @get-page="onSearch" />
  </div>
</template>

<script>
import crud from '@/mixins/crud';
import Edit from '@/views/brand/page2/edit';
import { http_brand } from '@/api';
export default {
  name: 'Index',
  components: {
    Edit
  },
  mixins: [crud],
  data() {
    return {
      tableHeight: window.innerHeight - 400,
      request: http_brand,
      searchParams: {
        name: ''
      },
      options: [],
      tableData: [
      ],
      columns: [
        { prop: 'name', label: '品牌名称', minWidth: '500px' },
        { prop: 'updateTime', label: '更新日期', minWidth: '500px' }
      ]
    }
  },
  methods: {
    onAdd() {
      this.$refs.EditRef.open()
    },
    onFrozen() {},
    onEdit(item) {
      this.$refs.EditRef.open(item)
    }
  }
}
</script>

<style scoped lang="scss">
.log-page {

  display: flex;
  flex-direction: column;
  background-color: #fff;
  height: 100%;
}
</style>
